@extends('admin/layout.app')

@section('title', '职位绑定权限')

@section('content')
    @if (count($errors) > 0)
        <div class="col-lg-9">
            <div class="alert alert-danger">
                <ul>
                    @if(is_object($errors))
                        @foreach($errors->all() as $error)
                            <li>{{$error}}</li>
                        @endforeach
                    @else
                        <li>{{$errors}}</li>
                    @endif
                </ul>
            </div>
        </div>
    @endif
    <div class="col-lg-10">
        <h2>职位名称：{{$role_info['name']}}</h2>
        <form class="form-horizontal" action="/admin/role_menu/{{$role_info['id']}}" method="post">
            <input type="hidden" value="{{$role_info['id']}}" name="role_id"/>
            <input type="hidden" value="{{$role_info['name']}}" name="name"/>
            {{csrf_field()}}
            <table class="table menu_table">
                <thead>
                <tr>
                    <th>请勾选权限：</th>
                </tr>
                </thead>
                <tbody>
                @if($menu_list)
                    @foreach($menu_list as $key=>$item)
                        <tr id="menu-{{ $item['id'] }}"
                            class="menu {{ $item['parent_id'] !=0 ? 'hidden' : '' }}" data-parent="{{ $item['parent_id'] !=0 ? 'menu-'.$item['parent_id'] : '' }}">
                            <td>
                                {{ str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;|--',$item['level']) }}
                                <i class="menu-arrow role-arrow-switch"></i>
                                <label><input type="checkbox" name="menu_ids[]"
                                              value="{{$item['id']}}" {{ in_array($item['id'],$related_menu) ? 'checked' : '' }}>{{ $item['name'] }}
                                </label>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-10">
                    <button type="submit" class="btn btn-default">保存</button>
                </div>
            </div>
        </form>
    </div>
@endsection
